<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        #ball {
            background-color: red;
            width: 50px;
            height: 50px;
            border-radius: 50%;
            position: absolute;
        }
    </style>
</head>
<body>
<--  -->
<script>
    var ball = document.getElementById('ball');
    window.onkeydown = function(e){
        console.log(e);
        if (e.key == 'ArrowRight'){
           location='http://www.baidu.com'
        } else if (e.key == 'ArrowLeft'){
            location='http://www.qq.com'
        }
//        if (e.)
    }
</script>
</body>
</html>